package com.hotrepalce;

import java.lang.reflect.Method;

/**
 * @author: csh
 * @Date: 2021/12/25 10:53
 * @Description:
 */
public class HotRun {
    public static void main(String[] args) {
        while (true){
            try {
                //1.创建自定义类加载器的实例
                MyClassLoader myClassLoader = new MyClassLoader("\\Users\\csh\\Documents\\ideaworkspace\\jdk8\\target\\classes\\");
                Class<?> aClass = myClassLoader.findClass("com.hotrepalce.HotTest");
                //运行方法
                Object o = aClass.newInstance();
                //运行类中指定的方法
                Method main = aClass.getMethod("main2");
                //调用
                main.invoke(o);

            }catch (Exception e){
                e.printStackTrace();

                try {
                    Thread.sleep(5000);
                } catch (InterruptedException interruptedException) {
                    interruptedException.printStackTrace();
                }
            }
        }
    }
}
